\bigskip
\bigskip
{\magonebf  6.1.4 Polygons (polygon)}

{\bf 1. Definition}

An instance $P$ of the data type $polygon$ is a simple polygon 
in the two-dimensional plane defined by the sequence of its vertices
in clockwise order. The number of vertices is called the size 
of $P$. A polygon with empty vertex sequence is called empty.

\def\name{$polygon$}
\def\type{$polygon$}

{\bf 2. Creation}

a) \create P (list\<point\>\  pl)

b) \create P {}


introduces a variable \var\ of type \name. \var\ is initialized to the
polygon with vertex sequence $pl$. \precond The vertices in $pl$ are given 
in clockwise order and define a simple polygon.  Variant b) creates the empty 
polygon and assigns it to \var.

\bigskip
{\bf 3. Operations}

\medskip
\+\cleartabs & \hskip 2.6truecm & \hskip 5.1truecm &\cr
\+\op list\<point\>   vertices {}
                           {returns the vertex sequence of \var.}
\smallskip
\+\op list\<segment\> segments {}
                           {returns the sequence of bounding segments}
\+\nop                     {of \var\ in clockwise order.}
\smallskip
\+\op list\<point\>   intersection {line\ l}
                           {returns $P \cap l$ as a list of points.}
\smallskip
\+\op list\<point\>   intersection {segment\ s}
                           {returns $P \cap s$ as a list of points.}
\smallskip
\+\op list\<polygon\> intersection {polygon\ Q}
                           {returns $P \cap Q$ as a list of points.}
\smallskip
\+\op bool          inside {point\ p}
                           {returns true if $p$ lies inside of $P$,}
\+\nop                     {false otherwise.}
\smallskip
\+\op bool          outside {point\ p}
                           {returns !\var.inside($p$).}
\smallskip
\+\op polygon       translate {vector\ v} {}
\+\nop                     {returns $P+v$, i.e., the polygon created by}
\+\nop                     {translating $P$ by vector $v$. \precond $v$}
\+\nop                     {has dimension 2.}
\smallskip
\+\op polygon       translate {double\ \alpha,\ double\ d} {}
\+\nop                    {returns the polygon created by a translation}
\+\nop                    {of \var\ in direction $\alpha$ by distance $d$}
\smallskip
\+\op polygon       rotate {point\ q,\ double\ \alpha}
                          {returns the polygon created by a rotation of}
\+\nop                    {$P$ about point $q$ by angle $\alpha$.}
\smallskip
\+\op double          size {}
                           {returns the size of \var.}
\smallskip
\+\op bool          empty {}
                           {returns true if \var\ is empty, false otherwise.}
\smallskip


\bigskip
{\bf 4. Operators }
\medskip
\+&$bool$       &$polygon$ ==    $polygon$     &test for equality\cr
\smallskip
\+&$bool$       &$polygon$\ !=\  $polygon$     &test for inequality\cr

